#include <iostream>
#include<cmath>
using namespace std;
int sum;
int topcost(int* cost, int n)
{
	if(n == 0 || n == 1)
		return sum;
	return cost[n] + topcost(cost, n - 1) + topcost(cost, n - 2);
}
int main()
{
	int n = 0;
	cin >> n;
	int cost[n];
	for(int i = 0; i < n; i++){
		cin >> cost[i];
	}
	int top = topcost(cost, n);
	cout << top << endl;
	return 0;
}
